const state = {
    //已选规格的id的组合
    selectAttrIds : [],
    selectAttrTypeOptions : [],
    attrTypeOptions : []
}

const mutations = {
    //设置规格选项数据
    setAttrTypeOptions (state, payload) {
        state.attrTypeOptions = payload;
    },
    setSelectAttrIds (state, payload) {
        //设置已选择的规格id
        state.selectAttrIds = payload;
        //设置已选择的规格选项，为表格设置表头环节准备
        state.selectAttrTypeOptions = payload.filter(item => item != null).map(v => {
            return state.attrTypeOptions.filter(item => item.id == v)[0]
        })
    },
    resetProduct (state) {
        state.selectAttrIds = [];
        state.selectAttrTypeOptions = [];
    }
}

export default {
    namespace : true,
    state,
    mutations
}